package com.qingkai.onlineshop.presentation.splash

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.qingkai.onlineshop.R
import com.qingkai.onlineshop.app.Route
import com.qingkai.onlineshop.ui.theme.OnLineShopAppTheme

/**
 *作者：created by 89270 on 2025/6/3 18:13
 *描述：
 */
@Composable
fun SplashScreen(navigateToRoute: (Route) -> Unit) {
    Box(
        modifier = Modifier
            .fillMaxSize()
            .background(MaterialTheme.colorScheme.background)
    ) {
        Image(
            painter = painterResource(id = R.drawable.intro_pic),
            contentDescription = "intro",
            modifier = Modifier.fillMaxSize(),
            contentScale = ContentScale.Crop
        )
        Column(
            modifier = Modifier
                .fillMaxWidth()
                .statusBarsPadding()
                .padding(horizontal = 16.dp)
                .padding(top = 60.dp)
        ) {
            Text(
                text = stringResource(R.string.str_intro),
                style = MaterialTheme.typography.displayMedium,
                fontWeight = FontWeight.Bold,
                color = Color.White
            )
            FilledTonalButton(
                onClick = { navigateToRoute(Route.Dashboard) },
                modifier = Modifier
                    .align(Alignment.CenterHorizontally)
                    .padding(top = 32.dp),
                colors = ButtonDefaults.filledTonalButtonColors(
                    contentColor = MaterialTheme.colorScheme.primary,
                )
            ) {
                Text(text = stringResource(R.string.str_start))
            }
        }
    }

}

@Preview(showBackground = true)
@Composable
private fun SplashScreenPreview() {
    OnLineShopAppTheme {
        SplashScreen(navigateToRoute = {})
    }
}